﻿using MobiSms.DataModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using MobiSms.Enums;

namespace MobiSms.ViewModel
{
    public class MainViewModel : ViewModelBase
    {
        public MainViewModel()
        {
            LoadSerials();
        }

        private ObservableCollection<SerialInfo> _itemsOfSerial;
        public ObservableCollection<SerialInfo> ItemsOfSerial
        {
            get { return _itemsOfSerial; }
            set
            {
                _itemsOfSerial = value;
                RaisePropertyChanged(() => ItemsOfSerial);
                ////Type t = GetType();
                //if (ItemsOfSerial != null && ItemsOfSerial.Count > 0 && GetType() == typeof(SerialCollectionViewModel))
                //{
                //    Invoke(typeof(SerialCollectionViewModel), "QueryBalance", null);
                //}
            }
        }

        #region Method
        private void LoadSerials()
        {
            IEnumerable<SerialInfo> items = Database.CollectionOfSerialNumbers;
            if (items.Count() > 0)
            {
                ItemsOfSerial = new ObservableCollection<SerialInfo>(items);
            }
        }

        #endregion
    }
}
